import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Name {
    /**
     * 2. 给定["a", "b", "a", "b", "c", "a", "b", "c", "b"]字符串数组，然后使用Map的key来保存数组中字符串元素，value保存该字符串元素的出现次数，最后统计出各字符串元素的出现次数。
     * @param args
     */
    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<Integer, String>();
        map.put(1, "Amy");
        map.put(2, "Joe");
        map.put(3, "Tom");
        map.put(4, "Susan");
        for (Integer key : map.keySet()) {
            System.out.println(key + " " + map.get(key)+"\n");
        }
        Scanner scan = new Scanner(System.in);
        System.out.println("输入人名");
        String name = scan.next();
        map.put(5, name);
        map.remove(4);
        if (map.containsKey(3)) {
            map.put(3, "Tommy");
        }
        for (Integer key : map.keySet()) {
            System.out.println(key + " " + map.get(key));
        }
    }
}
